package com.yanqu.road.server.cmd.activity.gold;

import com.yanqu.road.pb.activity.ActivityDisperseGoldProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.log.LogMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_ACTIVITY_DISPERSE_GOLD_CLIENT_UPLOAD_RESULT, desc = "客户端玩家操作结果上传")
public class PlayerActionResultUploadCmd extends AbstractCommand {

    ActivityDisperseGoldProto.PlayerActionResultUpLoadMsg msg;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        msg = ActivityDisperseGoldProto.PlayerActionResultUpLoadMsg.parseFrom(packet.getBytes());
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        if(msg != null){
            for(ActivityDisperseGoldProto.PlayerActionResultUpLoadInfo info: msg.getResultListList()){
                //if(ActivityDisperseGoldMgr.getDisperseGoldInfo(info.getDisperseId()) == null){
                //    continue;
                //}
                LogMgr.addLogActivityDispGoldClientResult(info.getDisperseId(), player.getUserId(), info.getActivityId(), info.getActivityType(),
                        info.getResultType(), info.getActionTime(), info.getReward());
            }
        }
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
